package com.rjt.qrcode.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.rjt.qrcode.dto.QrCodeVisitDto;
import com.rjt.qrcode.model.QrCodeVisitModel;

public interface QrCodeVisitRepository extends JpaRepository<QrCodeVisitModel, Integer> {

	@Query("select new com.rjt.qrcode.dto.QrCodeVisitDto(t.region,t.city,count(t.qId)) from QrCodeVisitModel t where t.qId=:qId  GROUP BY t.region,t.city ")
	List<QrCodeVisitDto> countByRIdAndArea(@Param(value = "qId") String qId);
	
	@Query("select new com.rjt.qrcode.dto.QrCodeVisitDto(DATE_FORMAT(createDate, '%Y-%m-%d'),count(t.qId)) from QrCodeVisitModel t where t.qId=:qId  GROUP BY DATE_FORMAT(createDate, '%Y-%m-%d') ")
	List<QrCodeVisitDto> countByRIdAndDate(@Param(value = "qId") String qId);
}
